]> dgit.raspbian.org Git - gnome-shell.git/commitdiff
shell-util: Add API to check for X11 extensions
authorJonas Ådahl <jadahl@gmail.com>
Tue, 1 Oct 2019 09:55:33 +0000 (11:55 +0200)
committerJonas Ådahl <jadahl@gmail.com>
Thu, 20 Feb 2020 11:14:55 +0000 (11:14 +0000)
Will be used to disable animations when running inside Xvnc. This was
done in gsd-xsettings before.

https://gitlab.gnome.org/GNOME/gnome-shell/merge_requests/757

src/shell-util.c
src/shell-util.h

index f344ec50bb191cf6365284ec80f10e5177e7ace3..918dcdf0b755b954f896846323073f1ca0bc6fb3 100644 (file)
@@ -20,6 +20,8 @@
 #include <glib/gi18n-lib.h>
 #include <gtk/gtk.h>
 #include <gdk-pixbuf/gdk-pixbuf.h>
+#include <meta/display.h>
+#include <meta/meta-x11-display.h>
 
 #include <locale.h>
 #ifdef HAVE__NL_TIME_FIRST_WEEKDAY
@@ -639,3 +641,27 @@ shell_util_sd_notify (void)
    * our environment. */
   sd_notify (1, "READY=1");
 }
+
+/**
+ * shell_util_has_x11_display_extension:
+ * @display: A #MetaDisplay
+ * @extension: An X11 extension
+ *
+ * If the corresponding X11 display provides the passed extension, return %TRUE,
+ * otherwise %FALSE. If there is no X11 display, %FALSE is passed.
+ */
+gboolean
+shell_util_has_x11_display_extension (MetaDisplay *display,
+                                      const char  *extension)
+{
+  MetaX11Display *x11_display;
+  Display *xdisplay;
+  int op, event, error;
+
+  x11_display = meta_display_get_x11_display (display);
+  if (!x11_display)
+    return FALSE;
+
+  xdisplay = meta_x11_display_get_xdisplay (x11_display);
+  return XQueryExtension (xdisplay, extension, &op, &event, &error);
+}
index acd031048f2f4464d74f61a33f66d09511d2abb3..220606de3b75446fe540ba4705777fddd63bbb56 100644 (file)
@@ -66,6 +66,9 @@ gboolean shell_util_stop_systemd_unit  (const char  *unit,
 
 void shell_util_sd_notify (void);
 
+gboolean shell_util_has_x11_display_extension (MetaDisplay *display,
+                                               const char  *extension);
+
 G_END_DECLS
 
 #endif /* __SHELL_UTIL_H__ */